package xin.nick.config;

import com.alibaba.cloud.sentinel.rest.SentinelClientHttpResponse;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.fastjson.JSON;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;

public class SentinelExceptionHandler {

    //限流熔断业务逻辑
    public static SentinelClientHttpResponse handlerException(HttpRequest request, byte[] body, ClientHttpRequestExecution execution, BlockException ex) {
        String message ="系统错误 (限流熔断业务逻辑)";
        return new SentinelClientHttpResponse(message);
    }
    //异常降级业务逻辑
    public static SentinelClientHttpResponse handleFallback(HttpRequest request, byte[] body, ClientHttpRequestExecution execution, BlockException ex) {
        String message = "系统错误 (异常降级业务逻辑)";
        return new SentinelClientHttpResponse(message);
    }
}